<script setup lang="ts">
import { ref } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();
const activeIndex = ref("traffic-indicators");

const handleSelect = (key) => {
  router.push(`/${key}`);
};
</script>

<template>
  <el-container class="layout-container">
    <el-header height="60px">
      <div class="header-content">
        <div class="logo">武汉市交通大数据分析系统</div>
        <el-menu
          :default-active="activeIndex"
          class="nav-menu"
          mode="horizontal"
          @select="handleSelect"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-menu-item index="traffic-indicators">交通指标分析</el-menu-item>
          <el-menu-item index="traffic-jam">道路拥堵分析</el-menu-item>
          <el-menu-item index="weather">天气信息</el-menu-item>
          <el-menu-item index="travel-advice">出行建议</el-menu-item>
        </el-menu>
      </div>
    </el-header>

    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</template>

<style scoped lang="scss">
.layout-container {
  height: 100vh;
  background-color: #f0f2f5;
}

.el-header {
  padding: 0;
  background-color: #545c64;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.header-content {
  height: 100%;
  display: flex;
  align-items: center;
}

.logo {
  padding: 0 20px;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  white-space: nowrap;
}

.nav-menu {
  flex: 1;
  border: none;
}

.el-main {
  padding: 20px;
}
</style>
